home *** CD-ROM | disk | FTP | other *** search
/ Enter Special 5: Digital Photography / ENTER Special 05.iso / Grafika / Paint Shop Pro 8.0 / psp800ev.exe / Data1.cab / __init__.py3 < prev    next >
Encoding:
Text File  |  2003-04-22  |  3.7 KB  |  126 lines

  1. """W3C Document Object Model implementation for Python.
  2.  
  3. The Python mapping of the Document Object Model is documented in the
  4. Python Library Reference in the section on the xml.dom package.
  5.  
  6. This package contains the following modules:
  7.  
  8. minidom -- A simple implementation of the Level 1 DOM with namespace
  9.            support added (based on the Level 2 specification) and other
  10.            minor Level 2 functionality.
  11.  
  12. pulldom -- DOM builder supporting on-demand tree-building for selected
  13.            subtrees of the document.
  14.  
  15. """
  16.  
  17.  
  18. class Node:
  19.     """Class giving the NodeType constants."""
  20.  
  21.     # DOM implementations may use this as a base class for their own
  22.     # Node implementations.  If they don't, the constants defined here
  23.     # should still be used as the canonical definitions as they match
  24.     # the values given in the W3C recommendation.  Client code can
  25.     # safely refer to these values in all tests of Node.nodeType
  26.     # values.
  27.  
  28.     ELEMENT_NODE                = 1
  29.     ATTRIBUTE_NODE              = 2
  30.     TEXT_NODE                   = 3
  31.     CDATA_SECTION_NODE          = 4
  32.     ENTITY_REFERENCE_NODE       = 5
  33.     ENTITY_NODE                 = 6
  34.     PROCESSING_INSTRUCTION_NODE = 7
  35.     COMMENT_NODE                = 8
  36.     DOCUMENT_NODE               = 9
  37.     DOCUMENT_TYPE_NODE          = 10
  38.     DOCUMENT_FRAGMENT_NODE      = 11
  39.     NOTATION_NODE               = 12
  40.  
  41.  
  42. #ExceptionCode
  43. INDEX_SIZE_ERR                 = 1
  44. DOMSTRING_SIZE_ERR             = 2
  45. HIERARCHY_REQUEST_ERR          = 3
  46. WRONG_DOCUMENT_ERR             = 4
  47. INVALID_CHARACTER_ERR          = 5
  48. NO_DATA_ALLOWED_ERR            = 6
  49. NO_MODIFICATION_ALLOWED_ERR    = 7
  50. NOT_FOUND_ERR                  = 8
  51. NOT_SUPPORTED_ERR              = 9
  52. INUSE_ATTRIBUTE_ERR            = 10
  53. INVALID_STATE_ERR              = 11
  54. SYNTAX_ERR                     = 12
  55. INVALID_MODIFICATION_ERR       = 13
  56. NAMESPACE_ERR                  = 14
  57. INVALID_ACCESS_ERR             = 15
  58.  
  59.  
  60. class DOMException(Exception):
  61.     """Abstract base class for DOM exceptions.
  62.     Exceptions with specific codes are specializations of this class."""
  63.  
  64.     def __init__(self, *args, **kw):
  65.         if self.__class__ is DOMException:
  66.             raise RuntimeError(
  67.                 "DOMException should not be instantiated directly")
  68.         apply(Exception.__init__, (self,) + args, kw)
  69.  
  70.     def _get_code(self):
  71.         return self.code
  72.  
  73.  
  74. class IndexSizeErr(DOMException):
  75.     code = INDEX_SIZE_ERR
  76.  
  77. class DomstringSizeErr(DOMException):
  78.     code = DOMSTRING_SIZE_ERR
  79.  
  80. class HierarchyRequestErr(DOMException):
  81.     code = HIERARCHY_REQUEST_ERR
  82.  
  83. class WrongDocumentErr(DOMException):
  84.     code = WRONG_DOCUMENT_ERR
  85.  
  86. class InvalidCharacterErr(DOMException):
  87.     code = INVALID_CHARACTER_ERR
  88.  
  89. class NoDataAllowedErr(DOMException):
  90.     code = NO_DATA_ALLOWED_ERR
  91.  
  92. class NoModificationAllowedErr(DOMException):
  93.     code = NO_MODIFICATION_ALLOWED_ERR
  94.  
  95. class NotFoundErr(DOMException):
  96.     code = NOT_FOUND_ERR
  97.  
  98. class NotSupportedErr(DOMException):
  99.     code = NOT_SUPPORTED_ERR
  100.  
  101. class InuseAttributeErr(DOMException):
  102.     code = INUSE_ATTRIBUTE_ERR
  103.  
  104. class InvalidStateErr(DOMException):
  105.     code = INVALID_STATE_ERR
  106.  
  107. class SyntaxErr(DOMException):
  108.     code = SYNTAX_ERR
  109.  
  110. class InvalidModificationErr(DOMException):
  111.     code = INVALID_MODIFICATION_ERR
  112.  
  113. class NamespaceErr(DOMException):
  114.     code = NAMESPACE_ERR
  115.  
  116. class InvalidAccessErr(DOMException):
  117.     code = INVALID_ACCESS_ERR
  118.  
  119.  
  120. XML_NAMESPACE = "http://www.w3.org/XML/1998/namespace"
  121. XMLNS_NAMESPACE = "http://www.w3.org/2000/xmlns/"
  122. XHTML_NAMESPACE = "http://www.w3.org/1999/xhtml"
  123. EMPTY_NAMESPACE = None
  124.  
  125. from domreg import getDOMImplementation,registerDOMImplementation
  126.